package com.seaside.park.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.seaside.common.bean.Result;
import com.seaside.parkCommon.mapper.CameraMapper;
import com.seaside.parkCommon.vo.CameraVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(tags="监控")
@RestController
public class MonitorAPI {

    @Autowired
    private CameraMapper cameraMapper;

    @ApiOperation(value = "查看监控", response = Result.class)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="header",name="bearer",dataTypeClass=String.class,required=true,value="用户token"),
            @ApiImplicitParam(paramType="query",name="parkId",dataTypeClass=Integer.class,required=true,value="车位号ID")
    })
    @PostMapping("/api/monitor")
    public Result monitor(Integer parkId) {
        Result<String> result;
        try{
            CameraVO cameraVO = cameraMapper.getCameraByParkId(parkId);
            result =  Result.OK("查询成功");
            result.setData(cameraVO.getRtspUrl());
        }catch(Exception e) {
            result = Result.Error("查询错误：" + e.getMessage());
        }
        return result;
    }
}
